package com.sys.entity;

import java.util.ArrayList;
import java.util.List;

public class Student extends Person {
    private String major;
    private List<Course> selectedCourses = new ArrayList<>();

    public Student(String id, String name, String gender, String major) {
        super(id, name, gender);
        this.major = major;
    }

    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + "同学选择了" + course.getCourseName() + "课程");
    }

    public void dropCourse(Course course) {
        if (selectedCourses.contains(course)) {
            selectedCourses.remove(course);
            System.out.println(name + "同学退选了" + course.getCourseName() + "课程");
        } else {
            System.out.println(name + "同学目前没有选课，无法退课");
        }
    }

    public void printCourseSchedule() {
        if (!selectedCourses.isEmpty()) {
            System.out.println("学生课表：");
            System.out.println("学生编号：" + id);
            for (Course course : selectedCourses) {
                System.out.println("课程名称：" + course.getCourseName());
                System.out.println("上课地点：" + course.getLocation());
                System.out.println("上课时间：" + course.getTime());
                System.out.println("授课教师：" + course.getTeacher().getName());
            }
        } else {
            System.out.println(name + "同学目前没有选课，课表为空");
        }
    }
}